Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(input): add opt-in support for input[range] #15229

Closed

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Oct 8, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature

What is the current behavior? (You can also link to an open issue here)
input[range] is not supported.

What is the new behavior (if this is a feature change)?
Support for input[range] can be opted into, by using the ng-range-input attribute.

Does this PR introduce a breaking change?
No.

Please check if the PR fulfills these requirements

Other information:
This is a POC. Docs need to be updated.

@gkalpak gkalpak added this to the 1.5.9 milestone Oct 8, 2016
@gkalpak gkalpak changed the title Opt in support for input range feat(input): add opt-in support for input[range] Oct 8, 2016
@petebacondarwin
Copy link
Contributor

My initial comment is that we need to check that other things that were changed in these commits are not impacted, such as ngMax, ngMin, ngStep(?), etc.

@gkalpak
Copy link
Member Author

gkalpak commented Oct 8, 2016

With the exception of this line (which should not affect other inputs afaict), there has been no change in any input type other than range.
(There are a couple of minor refactorings, but no actual change.)

function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
badInputChecker(scope, element, attr, ctrl);
numberFormatterParser(ctrl);
baseInputType(scope, element, attr, ctrl, $sniffer, $browser);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably doesn't make any difference but we should probably switch this line with the line above to ensure the order of the code is the same as previously.

@@ -883,7 +883,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
ctrl.$viewValue = ctrl.$$lastCommittedViewValue = viewValue;
ctrl.$render();

ctrl.$$runValidators(modelValue, viewValue, noop);
// It is possible that model and view value have been updated during render
ctrl.$$runValidators(ctrl.$modelValue, ctrl.$viewValue, noop);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is not a breaking change because if $render didn't change the value then it will be the same as before, right? I think it is only the range input that is likely to do this...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Among the built-in $render function, yes. But the truth is it could be a breaking change for user defined $render functions (theoretically).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although even in that case, it could be considered a fix 😁

['scheme://例子.测试', true],
['scheme://उदाहरण.�रीक्षा', true],
['scheme://उदाहरण.???ीक्षा', true],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I wonder if this change is right? It looks like previously the strings were UTF-16?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops! No idea how that sneaked in.

@@ -351,7 +351,7 @@ describe('validators', function() {


it('should accept values of any length when maxlength is non-numeric', function() {
var inputElm = helper.compileInput('<input type="text" ng-model="value" ng-maxlength="{{maxlength}}" />');
var inputElm = helper.compileInput('<input type="text" ng-model="value" ng-maxlength="maxlength" />');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that this was a bad test in the first place is not really part of this PR? Perhaps, if so, then when you are squashing all this, we move this change into its own commit?

@petebacondarwin
Copy link
Contributor

petebacondarwin commented Oct 8, 2016

OK, I think this is about right.
Let's check with @Narretz and then if @tbosch thinks it is useful we can fix up the docs and merge into 1.5

@gkalpak gkalpak force-pushed the opt-in-support-for-input-range branch from 5e09fa7 to 60ccaca Compare October 8, 2016 14:24
@Narretz
Copy link
Contributor

Narretz commented Oct 9, 2016

I think it's pretty unorthodox of us to provide an opt-in for a regular input in core, especially since it becomes the default in 1.6. We are also forcing Googlers to update to 1.6 sooner if we leave it out of 1.5 ;) But the implementation is clean, so we might as well. Although I would like to see the refactor commits that affect other inputs in a separate commit.

This commit re-applies the related (previously reverted) commits. A follow-up
commit will make the support opt-in in order to avoid a breaking change.

Included commits:

- 296da4b - `feat(input): add support for binding to input[type=range]`
  (previously reverted with 6a167e8)

- b78539b - `fix(input[range]): correctly handle min/max; remove ngMin/ngMax support`
  (previously reverted with aa60491)

- 90c08b8 - `feat(input[range]): support step`
  (previously reverted with 5b633d8)
@gkalpak gkalpak force-pushed the opt-in-support-for-input-range branch from 60ccaca to c94a921 Compare October 10, 2016 15:44
@gkalpak
Copy link
Member Author

gkalpak commented Oct 10, 2016

I have tidied this up and fixed docs. (I also changed ng-range-input to ng-input-range as it seemed more consistent).

gkalpak added a commit that referenced this pull request Oct 10, 2016
@petebacondarwin
Copy link
Contributor

Landed in 1.5.x as

@gkalpak gkalpak deleted the opt-in-support-for-input-range branch October 10, 2016 19:16
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants